{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Data\n",
    "\n",
    "The data consists of three tables: ratings, books info, and users info."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "b'Skipping line 6452: expected 8 fields, saw 9\\nSkipping line 43667: expected 8 fields, saw 10\\nSkipping line 51751: expected 8 fields, saw 9\\n'\n",
      "b'Skipping line 92038: expected 8 fields, saw 9\\nSkipping line 104319: expected 8 fields, saw 9\\nSkipping line 121768: expected 8 fields, saw 9\\n'\n",
      "b'Skipping line 144058: expected 8 fields, saw 9\\nSkipping line 150789: expected 8 fields, saw 9\\nSkipping line 157128: expected 8 fields, saw 9\\nSkipping line 180189: expected 8 fields, saw 9\\nSkipping line 185738: expected 8 fields, saw 9\\n'\n",
      "b'Skipping line 209388: expected 8 fields, saw 9\\nSkipping line 220626: expected 8 fields, saw 9\\nSkipping line 227933: expected 8 fields, saw 11\\nSkipping line 228957: expected 8 fields, saw 10\\nSkipping line 245933: expected 8 fields, saw 9\\nSkipping line 251296: expected 8 fields, saw 9\\nSkipping line 259941: expected 8 fields, saw 9\\nSkipping line 261529: expected 8 fields, saw 9\\n'\n",
      "C:\\Users\\Susan\\Anaconda3\\lib\\site-packages\\IPython\\core\\interactiveshell.py:2717: DtypeWarning: Columns (3) have mixed types. Specify dtype option on import or set low_memory=False.\n",
      "  interactivity=interactivity, compiler=compiler, result=result)\n"
     ]
    }
   ],
   "source": [
    "books = pd.read_csv('BX-Books.csv', sep=';', error_bad_lines=False, encoding=\"latin-1\")\n",
    "books.columns = ['ISBN', 'bookTitle', 'bookAuthor', 'yearOfPublication', 'publisher', 'imageUrlS', 'imageUrlM', 'imageUrlL']\n",
    "users = pd.read_csv('BX-Users.csv', sep=';', error_bad_lines=False, encoding=\"latin-1\")\n",
    "users.columns = ['userID', 'Location', 'Age']\n",
    "ratings = pd.read_csv('BX-Book-Ratings.csv', sep=';', error_bad_lines=False, encoding=\"latin-1\")\n",
    "ratings.columns = ['userID', 'ISBN', 'bookRating']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Ratings Data\n",
    "\n",
    "The ratings data set provides a list of ratings that users have given to books. It includes 1,149,780 records and 3 fields: userID, ISBN, and rating."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1149780, 3)\n",
      "['userID', 'ISBN', 'bookRating']\n"
     ]
    }
   ],
   "source": [
    "print(ratings.shape)\n",
    "print(list(ratings.columns))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>userID</th>\n",
       "      <th>ISBN</th>\n",
       "      <th>bookRating</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>276725</td>\n",
       "      <td>034545104X</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>276726</td>\n",
       "      <td>0155061224</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>276727</td>\n",
       "      <td>0446520802</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>276729</td>\n",
       "      <td>052165615X</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>276729</td>\n",
       "      <td>0521795028</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   userID        ISBN  bookRating\n",
       "0  276725  034545104X           0\n",
       "1  276726  0155061224           5\n",
       "2  276727  0446520802           0\n",
       "3  276729  052165615X           3\n",
       "4  276729  0521795028           6"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratings.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Ratings Distribution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbMAAAE9CAYAAACBV4wvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmcXEW9/vHPcxO2yGIIIESBACIILlwdRb2yiewggiLi\nvt2I6FUBlU2uARECsvzUgNyogBs/FEG9bAIhBEEWHXCHIC4RkC3AhBAStuR7/6hqODQ9S8+c6U4l\nz/v16tdM16muqu7p6afPOXXOUURgZmZWsn/r9gDMzMxGymFmZmbFc5iZmVnxHGZmZlY8h5mZmRXP\nYWZmZsVzmJm1SdI5koo8pkXSJEkhaUo3++zGOLrZr40+h5kVSdL2+UOpelsg6RZJB0saO8L2PyTp\ns3WNdzQ0Pfclkh6V9HdJP5X0YUmr1NzfUv+awDOBNUXSVt0ei3WOfNC0lUjS9sDVwP8HLgUErAt8\nAHgF8K2ImDyC9mcBkyJiUotlKwBjIuLx4bZfh7x2+DvglFw0DtgA2Bl4HfA34B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qskXS/pcUl/lrS7pF5J54zmkzdr8JqZWdk2yD8bZyEfR7og5H8D95FC7ijSlX93yXXeAswE\njgMuyWWKX/pLAAACN0lEQVT3Auv108e7SFdHngy8BDgVOB44CEDSOODy3N8BpNMVnUa6ltWfRvj8\nzIbEYWZWGEmN/9sNgWnA74CfA0TEXODjTXX/AVwnaYN8Danf5MV/q2yyJF3ZvqWngLdHxNO53hbA\nu8lhRrp69ASgJyL+lev8DbhpZM/UbOgcZmZlmUAKl4aHgNdVr94r6f3AIcCmwAsqdV8GDOeCiFc3\ngiy7FVhH0goR8RTwOuDmRpABRMSvJd0/jL7MhsX7zMzK8ggpPN5AWgNbEThX0r8BSNoH+B5pUsh+\nud4++bHDPVv5vKb7T5LOrbdSvr8uMLfF41qVmY0Kr5mZleXpiOjNv98kaREpvPYjnYl8P+CmiGhs\nAkTSdqM8pvuAzVqUj8p1q8xa8ZqZWdl+QLr0xmH5/irAE0113tt0/8n8s67rSv0GeK2kFzcKJL0e\neFFN7ZsNymFmVrBIZwo/Hvh3STsCVwLbSjpK0lslnQrs2PSYJ0mTQt4l6c2SeiStOIJhnE3ad3ex\npLdLOoAUsnOBJSNo12zIHGZm5fsRcAfwBeB/gFOAzwAXkmY8vqfFYw4E1gJmkNasJg6384hYSDpo\ne1Eey5Q8lnnA/OG2a9YOXwLGzGonaSPgL8DkiDi72+OxZZ/DzMxGTNIRwD3AP0kHch8BrAFsHhFe\nO7NR59mMZlaHIJ28eCJpAsq1wOccZNYpXjMzM7PieQKImZkVz2FmZmbFc5iZmVnxHGZmZlY8h5mZ\nmRXPYWZmZsX7Px9/UWbcNSzhAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x141bb3b07f0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.rc(\"font\", size=15)\n",
    "ratings.bookRating.value_counts(sort=False).plot(kind='bar')\n",
    "plt.title('Rating Distribution\\n')\n",
    "plt.xlabel('Rating')\n",
    "plt.ylabel('Count')\n",
    "plt.savefig('system1.png', bbox_inches='tight')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Books dataset\n",
    "\n",
    "This dataset provides books details. It includes 271360 records and 8 fields: ISBN, book title, book author, publisher and so on."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(271360, 8)\n",
      "['ISBN', 'bookTitle', 'bookAuthor', 'yearOfPublication', 'publisher', 'imageUrlS', 'imageUrlM', 'imageUrlL']\n"
     ]
    }
   ],
   "source": [
    "print(books.shape)\n",
    "print(list(books.columns))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ISBN</th>\n",
       "      <th>bookTitle</th>\n",
       "      <th>bookAuthor</th>\n",
       "      <th>yearOfPublication</th>\n",
       "      <th>publisher</th>\n",
       "      <th>imageUrlS</th>\n",
       "      <th>imageUrlM</th>\n",
       "      <th>imageUrlL</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0195153448</td>\n",
       "      <td>Classical Mythology</td>\n",
       "      <td>Mark P. O. Morford</td>\n",
       "      <td>2002</td>\n",
       "      <td>Oxford University Press</td>\n",
       "      <td>http://images.amazon.com/images/P/0195153448.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0195153448.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0195153448.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0002005018</td>\n",
       "      <td>Clara Callan</td>\n",
       "      <td>Richard Bruce Wright</td>\n",
       "      <td>2001</td>\n",
       "      <td>HarperFlamingo Canada</td>\n",
       "      <td>http://images.amazon.com/images/P/0002005018.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0002005018.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0002005018.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0060973129</td>\n",
       "      <td>Decision in Normandy</td>\n",
       "      <td>Carlo D'Este</td>\n",
       "      <td>1991</td>\n",
       "      <td>HarperPerennial</td>\n",
       "      <td>http://images.amazon.com/images/P/0060973129.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0060973129.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0060973129.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0374157065</td>\n",
       "      <td>Flu: The Story of the Great Influenza Pandemic...</td>\n",
       "      <td>Gina Bari Kolata</td>\n",
       "      <td>1999</td>\n",
       "      <td>Farrar Straus Giroux</td>\n",
       "      <td>http://images.amazon.com/images/P/0374157065.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0374157065.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0374157065.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0393045218</td>\n",
       "      <td>The Mummies of Urumchi</td>\n",
       "      <td>E. J. W. Barber</td>\n",
       "      <td>1999</td>\n",
       "      <td>W. W. Norton &amp;amp; Company</td>\n",
       "      <td>http://images.amazon.com/images/P/0393045218.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0393045218.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0393045218.0...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         ISBN                                          bookTitle  \\\n",
       "0  0195153448                                Classical Mythology   \n",
       "1  0002005018                                       Clara Callan   \n",
       "2  0060973129                               Decision in Normandy   \n",
       "3  0374157065  Flu: The Story of the Great Influenza Pandemic...   \n",
       "4  0393045218                             The Mummies of Urumchi   \n",
       "\n",
       "             bookAuthor yearOfPublication                   publisher  \\\n",
       "0    Mark P. O. Morford              2002     Oxford University Press   \n",
       "1  Richard Bruce Wright              2001       HarperFlamingo Canada   \n",
       "2          Carlo D'Este              1991             HarperPerennial   \n",
       "3      Gina Bari Kolata              1999        Farrar Straus Giroux   \n",
       "4       E. J. W. Barber              1999  W. W. Norton &amp; Company   \n",
       "\n",
       "                                           imageUrlS  \\\n",
       "0  http://images.amazon.com/images/P/0195153448.0...   \n",
       "1  http://images.amazon.com/images/P/0002005018.0...   \n",
       "2  http://images.amazon.com/images/P/0060973129.0...   \n",
       "3  http://images.amazon.com/images/P/0374157065.0...   \n",
       "4  http://images.amazon.com/images/P/0393045218.0...   \n",
       "\n",
       "                                           imageUrlM  \\\n",
       "0  http://images.amazon.com/images/P/0195153448.0...   \n",
       "1  http://images.amazon.com/images/P/0002005018.0...   \n",
       "2  http://images.amazon.com/images/P/0060973129.0...   \n",
       "3  http://images.amazon.com/images/P/0374157065.0...   \n",
       "4  http://images.amazon.com/images/P/0393045218.0...   \n",
       "\n",
       "                                           imageUrlL  \n",
       "0  http://images.amazon.com/images/P/0195153448.0...  \n",
       "1  http://images.amazon.com/images/P/0002005018.0...  \n",
       "2  http://images.amazon.com/images/P/0060973129.0...  \n",
       "3  http://images.amazon.com/images/P/0374157065.0...  \n",
       "4  http://images.amazon.com/images/P/0393045218.0...  "
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "books.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Users dataset \n",
    "\n",
    "This dataset provides the user demographic information. It includes 278858 records and 3 fields: user id, location and age."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(278858, 3)\n",
      "['userID', 'Location', 'Age']\n"
     ]
    }
   ],
   "source": [
    "print(users.shape)\n",
    "print(list(users.columns))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>userID</th>\n",
       "      <th>Location</th>\n",
       "      <th>Age</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>nyc, new york, usa</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>stockton, california, usa</td>\n",
       "      <td>18.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>moscow, yukon territory, russia</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>porto, v.n.gaia, portugal</td>\n",
       "      <td>17.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>farnborough, hants, united kingdom</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   userID                            Location   Age\n",
       "0       1                  nyc, new york, usa   NaN\n",
       "1       2           stockton, california, usa  18.0\n",
       "2       3     moscow, yukon territory, russia   NaN\n",
       "3       4           porto, v.n.gaia, portugal  17.0\n",
       "4       5  farnborough, hants, united kingdom   NaN"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "users.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Age distribution\n",
    "\n",
    "The most active users are among 20-30s."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaoAAAE5CAYAAADBfWQbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X2cHWV99/HPl2AgGwgsQRaxaIgoCKY3tqlV2kJ4UIgV\nopQHqa1GeTVFi0hJbQOa3gGkBBSQm6gYn1J7iwgKdwwhIhEWVNAC0kqFBFQCCAKCG9bNJgTC7/7j\nmiPDcLKPZ8/MnvN9v17ntXuuueaa68pmz3dn5poZRQRmZmZVtU3ZHTAzMxuIg8rMzCrNQWVmZpXm\noDIzs0pzUJmZWaU5qMzMrNIcVGYVJalb0rqyt1lGP8rcrlWPg8pahqROSRslhaS/Lbs/NZKWZX2q\nvTZJelzSLZLOlTS9wds7QNIiSdMa2e5YkHSapLll98OqzUFlreQ9wHbAA8AHSu5LPR8E/hY4Gfgk\n8BgwH7hX0ul16r8N2GcE2zkA+N/AtBGsO9JtjtRpwNytLGt2X6yiti27A2YNdBJwE7Ac+LSk6RHx\ny5L7lPfNiHgyXyDpVcC1wIWSHomIb9SWRcTmZnRK0gRgu4job9Y2h6JKfbFyeY/KWoKkPyLtSfw7\ncDnwHFvZq5I0QdJCSQ9mh+F+Kun47HBZFA+ZSXqFpM9JekjSZkmPSloqabfR9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lOU894IXAQcCtwOvF/SpNzh\nv6ML9deSHvo3LSK+MHa9NmsMB5XZ+DCH9JjwSyLix/kFkn5IeuLqicBC0iPCV0i6mHQocAFpgsXz\nABHxvKT5wH9ImgKsAjYD04F3AsdGRH9TRmU2BD5HZTY+nAjcXwwpgIh4FriSNNHiSeAvgd1I088/\nDHwAmAD05tb5Bin8DiAdSrwa+BDwE1JomVWGH0Vv1uIk/TnwfeDQiLip7P6YDZeDyqzFSDqfNEni\nMWAf0uHAp4A3RsTzZfbNbCR8jsqs9WxHuqC3C/gd8F3gdIeUjVfeozIzs0rzZAozM6s0B5WZmVWa\ng8rMzCrNQWVmZpXmoDIzs0pzUJmZWaX9fysmsp6RPdZqAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x141b6761278>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "users.Age.hist(bins=[0, 10, 20, 30, 40, 50, 100])\n",
    "plt.title('Age Distribution\\n')\n",
    "plt.xlabel('Age')\n",
    "plt.ylabel('Count')\n",
    "plt.savefig('system2.png', bbox_inches='tight')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Recommendations based on rating counts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>bookRating</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ISBN</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0971880107</th>\n",
       "      <td>2502</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0316666343</th>\n",
       "      <td>1295</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0385504209</th>\n",
       "      <td>883</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0060928336</th>\n",
       "      <td>732</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0312195516</th>\n",
       "      <td>723</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            bookRating\n",
       "ISBN                  \n",
       "0971880107        2502\n",
       "0316666343        1295\n",
       "0385504209         883\n",
       "0060928336         732\n",
       "0312195516         723"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rating_count = pd.DataFrame(ratings.groupby('ISBN')['bookRating'].count())\n",
    "rating_count.sort_values('bookRating', ascending=False).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The book with ISBN \"0971880107\" received the most ratings. Let's find out which books are in the top 5."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ISBN</th>\n",
       "      <th>bookTitle</th>\n",
       "      <th>bookAuthor</th>\n",
       "      <th>yearOfPublication</th>\n",
       "      <th>publisher</th>\n",
       "      <th>imageUrlS</th>\n",
       "      <th>imageUrlM</th>\n",
       "      <th>imageUrlL</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0971880107</td>\n",
       "      <td>Wild Animus</td>\n",
       "      <td>Rich Shapero</td>\n",
       "      <td>2004</td>\n",
       "      <td>Too Far</td>\n",
       "      <td>http://images.amazon.com/images/P/0971880107.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0971880107.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0971880107.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0316666343</td>\n",
       "      <td>The Lovely Bones: A Novel</td>\n",
       "      <td>Alice Sebold</td>\n",
       "      <td>2002</td>\n",
       "      <td>Little, Brown</td>\n",
       "      <td>http://images.amazon.com/images/P/0316666343.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0316666343.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0316666343.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0385504209</td>\n",
       "      <td>The Da Vinci Code</td>\n",
       "      <td>Dan Brown</td>\n",
       "      <td>2003</td>\n",
       "      <td>Doubleday</td>\n",
       "      <td>http://images.amazon.com/images/P/0385504209.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0385504209.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0385504209.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0060928336</td>\n",
       "      <td>Divine Secrets of the Ya-Ya Sisterhood: A Novel</td>\n",
       "      <td>Rebecca Wells</td>\n",
       "      <td>1997</td>\n",
       "      <td>Perennial</td>\n",
       "      <td>http://images.amazon.com/images/P/0060928336.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0060928336.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0060928336.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0312195516</td>\n",
       "      <td>The Red Tent (Bestselling Backlist)</td>\n",
       "      <td>Anita Diamant</td>\n",
       "      <td>1998</td>\n",
       "      <td>Picador USA</td>\n",
       "      <td>http://images.amazon.com/images/P/0312195516.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0312195516.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0312195516.0...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         ISBN                                        bookTitle     bookAuthor  \\\n",
       "0  0971880107                                      Wild Animus   Rich Shapero   \n",
       "1  0316666343                        The Lovely Bones: A Novel   Alice Sebold   \n",
       "2  0385504209                                The Da Vinci Code      Dan Brown   \n",
       "3  0060928336  Divine Secrets of the Ya-Ya Sisterhood: A Novel  Rebecca Wells   \n",
       "4  0312195516              The Red Tent (Bestselling Backlist)  Anita Diamant   \n",
       "\n",
       "  yearOfPublication      publisher  \\\n",
       "0              2004        Too Far   \n",
       "1              2002  Little, Brown   \n",
       "2              2003      Doubleday   \n",
       "3              1997      Perennial   \n",
       "4              1998    Picador USA   \n",
       "\n",
       "                                           imageUrlS  \\\n",
       "0  http://images.amazon.com/images/P/0971880107.0...   \n",
       "1  http://images.amazon.com/images/P/0316666343.0...   \n",
       "2  http://images.amazon.com/images/P/0385504209.0...   \n",
       "3  http://images.amazon.com/images/P/0060928336.0...   \n",
       "4  http://images.amazon.com/images/P/0312195516.0...   \n",
       "\n",
       "                                           imageUrlM  \\\n",
       "0  http://images.amazon.com/images/P/0971880107.0...   \n",
       "1  http://images.amazon.com/images/P/0316666343.0...   \n",
       "2  http://images.amazon.com/images/P/0385504209.0...   \n",
       "3  http://images.amazon.com/images/P/0060928336.0...   \n",
       "4  http://images.amazon.com/images/P/0312195516.0...   \n",
       "\n",
       "                                           imageUrlL  \n",
       "0  http://images.amazon.com/images/P/0971880107.0...  \n",
       "1  http://images.amazon.com/images/P/0316666343.0...  \n",
       "2  http://images.amazon.com/images/P/0385504209.0...  \n",
       "3  http://images.amazon.com/images/P/0060928336.0...  \n",
       "4  http://images.amazon.com/images/P/0312195516.0...  "
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "most_rated_books = pd.DataFrame(['0971880107', '0316666343', '0385504209', '0060928336', '0312195516'], index=np.arange(5), columns = ['ISBN'])\n",
    "most_rated_books_summary = pd.merge(most_rated_books, books, on='ISBN')\n",
    "most_rated_books_summary"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The book that received the most ratings in this data set is Rich Shapero's Wild Animus. Something in common among these five most rated books - they are fictions or novels. The recommender suggests that novels and fictions are popular and likely receive more ratings. And if someone likes \"Wild Animus\", probably we should recommend him(her) \"The Lovely Bones: A Novel\"."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Recommendations based on correlations\n",
    "\n",
    "Find out the average rating and the number of ratings each book received."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>bookRating</th>\n",
       "      <th>ratingCount</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ISBN</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0971880107</th>\n",
       "      <td>1.019584</td>\n",
       "      <td>2502</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0316666343</th>\n",
       "      <td>4.468726</td>\n",
       "      <td>1295</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0385504209</th>\n",
       "      <td>4.652322</td>\n",
       "      <td>883</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0060928336</th>\n",
       "      <td>3.448087</td>\n",
       "      <td>732</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0312195516</th>\n",
       "      <td>4.334716</td>\n",
       "      <td>723</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            bookRating  ratingCount\n",
       "ISBN                               \n",
       "0971880107    1.019584         2502\n",
       "0316666343    4.468726         1295\n",
       "0385504209    4.652322          883\n",
       "0060928336    3.448087          732\n",
       "0312195516    4.334716          723"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "average_rating = pd.DataFrame(ratings.groupby('ISBN')['bookRating'].mean())\n",
    "average_rating['ratingCount'] = pd.DataFrame(ratings.groupby('ISBN')['bookRating'].count())\n",
    "average_rating.sort_values('ratingCount', ascending=False).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Observation: \n",
    "\n",
    "In this dataet, the book that received the most ratings is not highly rated at all. So if we were set to use recommendations based on rating counts, we would definitely make mistaks here."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### To ensure statistical significance, users with less than 200 ratings, and books with less than 100 ratings are excluded."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "counts1 = ratings['userID'].value_counts()\n",
    "ratings = ratings[ratings['userID'].isin(counts1[counts1 >= 200].index)]\n",
    "counts = ratings['bookRating'].value_counts()\n",
    "ratings = ratings[ratings['bookRating'].isin(counts[counts >= 100].index)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Rating matrix\n",
    "\n",
    "Convert the table to a 2D matrix. The matrix will be sparse because not every user rate every book."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(905, 207699)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>ISBN</th>\n",
       "      <th>0330299891</th>\n",
       "      <th>0375404120</th>\n",
       "      <th>0586045007</th>\n",
       "      <th>9022906116</th>\n",
       "      <th>9032803328</th>\n",
       "      <th>9044922564</th>\n",
       "      <th>9044922572</th>\n",
       "      <th>9044922718</th>\n",
       "      <th>9044923161</th>\n",
       "      <th>904492401X</th>\n",
       "      <th>...</th>\n",
       "      <th>UNGRANDHOMMED</th>\n",
       "      <th>X000000000</th>\n",
       "      <th>YOUTELLEM,AND</th>\n",
       "      <th>ZR903CX0003</th>\n",
       "      <th>\\0432534220\\\"\"</th>\n",
       "      <th>\\2842053052\\\"\"</th>\n",
       "      <th>b00005wz75</th>\n",
       "      <th>cn108465</th>\n",
       "      <th>cn113107</th>\n",
       "      <th>Ô½crosoft</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>userID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>254</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2276</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2766</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2977</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3363</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 207699 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "ISBN     0330299891   0375404120   0586045007   9022906116   9032803328  \\\n",
       "userID                                                                    \n",
       "254             NaN          NaN          NaN          NaN          NaN   \n",
       "2276            NaN          NaN          NaN          NaN          NaN   \n",
       "2766            NaN          NaN          NaN          NaN          NaN   \n",
       "2977            NaN          NaN          NaN          NaN          NaN   \n",
       "3363            NaN          NaN          NaN          NaN          NaN   \n",
       "\n",
       "ISBN     9044922564   9044922572   9044922718   9044923161   904492401X  \\\n",
       "userID                                                                    \n",
       "254             NaN          NaN          NaN          NaN          NaN   \n",
       "2276            NaN          NaN          NaN          NaN          NaN   \n",
       "2766            NaN          NaN          NaN          NaN          NaN   \n",
       "2977            NaN          NaN          NaN          NaN          NaN   \n",
       "3363            NaN          NaN          NaN          NaN          NaN   \n",
       "\n",
       "ISBN      ...      UNGRANDHOMMED  X000000000  YOUTELLEM,AND  ZR903CX0003  \\\n",
       "userID    ...                                                              \n",
       "254       ...                NaN         NaN            NaN          NaN   \n",
       "2276      ...                NaN         NaN            NaN          NaN   \n",
       "2766      ...                NaN         NaN            NaN          NaN   \n",
       "2977      ...                NaN         NaN            NaN          NaN   \n",
       "3363      ...                NaN         NaN            NaN          NaN   \n",
       "\n",
       "ISBN    \\0432534220\\\"\"  \\2842053052\\\"\"  b00005wz75  cn108465  cn113107  \\\n",
       "userID                                                                   \n",
       "254                NaN             NaN         NaN       NaN       NaN   \n",
       "2276               NaN             NaN         NaN       NaN       NaN   \n",
       "2766               NaN             NaN         NaN       NaN       NaN   \n",
       "2977               NaN             NaN         NaN       NaN       NaN   \n",
       "3363               NaN             NaN         NaN       NaN       NaN   \n",
       "\n",
       "ISBN    Ô½crosoft  \n",
       "userID             \n",
       "254           NaN  \n",
       "2276          NaN  \n",
       "2766          NaN  \n",
       "2977          NaN  \n",
       "3363          NaN  \n",
       "\n",
       "[5 rows x 207699 columns]"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratings_pivot = ratings.pivot(index='userID', columns='ISBN').bookRating\n",
    "userID = ratings_pivot.index\n",
    "ISBN = ratings_pivot.columns\n",
    "print(ratings_pivot.shape)\n",
    "ratings_pivot.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's find out which books are correlated with the 2nd most rated book \"The Lovely Bones: A Novel\". To blatantly quote from the Wikipedia: It is the story of a teenage girl who, after being raped and murdered, watches from her personal Heaven as her family and friends struggle to move on with their lives while she comes to terms with her own death."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Susan\\Anaconda3\\lib\\site-packages\\numpy\\lib\\function_base.py:3154: RuntimeWarning: Degrees of freedom <= 0 for slice\n",
      "  c = cov(x, y, rowvar)\n",
      "C:\\Users\\Susan\\Anaconda3\\lib\\site-packages\\numpy\\lib\\function_base.py:3088: RuntimeWarning: divide by zero encountered in double_scalars\n",
      "  c *= 1. / np.float64(fact)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pearsonR</th>\n",
       "      <th>ratingCount</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ISBN</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0316666343</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1295</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0312291639</th>\n",
       "      <td>0.471872</td>\n",
       "      <td>354</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0316601950</th>\n",
       "      <td>0.434248</td>\n",
       "      <td>568</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0446610038</th>\n",
       "      <td>0.429712</td>\n",
       "      <td>391</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0446672211</th>\n",
       "      <td>0.421478</td>\n",
       "      <td>585</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0385265700</th>\n",
       "      <td>0.351635</td>\n",
       "      <td>319</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0345342968</th>\n",
       "      <td>0.316922</td>\n",
       "      <td>321</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0060930535</th>\n",
       "      <td>0.309860</td>\n",
       "      <td>494</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0375707972</th>\n",
       "      <td>0.308145</td>\n",
       "      <td>354</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0684872153</th>\n",
       "      <td>0.272480</td>\n",
       "      <td>326</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            pearsonR  ratingCount\n",
       "ISBN                             \n",
       "0316666343  1.000000         1295\n",
       "0312291639  0.471872          354\n",
       "0316601950  0.434248          568\n",
       "0446610038  0.429712          391\n",
       "0446672211  0.421478          585\n",
       "0385265700  0.351635          319\n",
       "0345342968  0.316922          321\n",
       "0060930535  0.309860          494\n",
       "0375707972  0.308145          354\n",
       "0684872153  0.272480          326"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bones_ratings = ratings_pivot['0316666343']\n",
    "similar_to_bones = ratings_pivot.corrwith(bones_ratings)\n",
    "corr_bones = pd.DataFrame(similar_to_bones, columns=['pearsonR'])\n",
    "corr_bones.dropna(inplace=True)\n",
    "corr_summary = corr_bones.join(average_rating['ratingCount'])\n",
    "corr_summary[corr_summary['ratingCount']>=300].sort_values('pearsonR', ascending=False).head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We obtained the books' ISBNs, but we need to find out the names of the books to see whether they make sense."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ISBN</th>\n",
       "      <th>bookTitle</th>\n",
       "      <th>bookAuthor</th>\n",
       "      <th>yearOfPublication</th>\n",
       "      <th>publisher</th>\n",
       "      <th>imageUrlS</th>\n",
       "      <th>imageUrlM</th>\n",
       "      <th>imageUrlL</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0312291639</td>\n",
       "      <td>The Nanny Diaries: A Novel</td>\n",
       "      <td>Emma McLaughlin</td>\n",
       "      <td>2003</td>\n",
       "      <td>St. Martin's Griffin</td>\n",
       "      <td>http://images.amazon.com/images/P/0312291639.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0312291639.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0312291639.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0316601950</td>\n",
       "      <td>The Pilot's Wife : A Novel</td>\n",
       "      <td>Anita Shreve</td>\n",
       "      <td>1999</td>\n",
       "      <td>Back Bay Books</td>\n",
       "      <td>http://images.amazon.com/images/P/0316601950.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0316601950.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0316601950.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0446610038</td>\n",
       "      <td>1st to Die: A Novel</td>\n",
       "      <td>James Patterson</td>\n",
       "      <td>2002</td>\n",
       "      <td>Warner Vision</td>\n",
       "      <td>http://images.amazon.com/images/P/0446610038.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0446610038.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0446610038.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0446672211</td>\n",
       "      <td>Where the Heart Is (Oprah's Book Club (Paperba...</td>\n",
       "      <td>Billie Letts</td>\n",
       "      <td>1998</td>\n",
       "      <td>Warner Books</td>\n",
       "      <td>http://images.amazon.com/images/P/0446672211.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0446672211.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0446672211.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0385265700</td>\n",
       "      <td>The Book of Ruth (Oprah's Book Club (Paperback))</td>\n",
       "      <td>Jane Hamilton</td>\n",
       "      <td>1990</td>\n",
       "      <td>Anchor</td>\n",
       "      <td>http://images.amazon.com/images/P/0385265700.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0385265700.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0385265700.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0345342968</td>\n",
       "      <td>Fahrenheit 451</td>\n",
       "      <td>RAY BRADBURY</td>\n",
       "      <td>1987</td>\n",
       "      <td>Del Rey</td>\n",
       "      <td>http://images.amazon.com/images/P/0345342968.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0345342968.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0345342968.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0060930535</td>\n",
       "      <td>The Poisonwood Bible: A Novel</td>\n",
       "      <td>Barbara Kingsolver</td>\n",
       "      <td>1999</td>\n",
       "      <td>Perennial</td>\n",
       "      <td>http://images.amazon.com/images/P/0060930535.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0060930535.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0060930535.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0375707972</td>\n",
       "      <td>The Reader</td>\n",
       "      <td>Bernhard Schlink</td>\n",
       "      <td>1999</td>\n",
       "      <td>Vintage Books USA</td>\n",
       "      <td>http://images.amazon.com/images/P/0375707972.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0375707972.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0375707972.0...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0684872153</td>\n",
       "      <td>Angela's Ashes (MMP) : A Memoir</td>\n",
       "      <td>Frank McCourt</td>\n",
       "      <td>1999</td>\n",
       "      <td>Scribner</td>\n",
       "      <td>http://images.amazon.com/images/P/0684872153.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0684872153.0...</td>\n",
       "      <td>http://images.amazon.com/images/P/0684872153.0...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         ISBN                                          bookTitle  \\\n",
       "0  0312291639                         The Nanny Diaries: A Novel   \n",
       "1  0316601950                         The Pilot's Wife : A Novel   \n",
       "2  0446610038                                1st to Die: A Novel   \n",
       "3  0446672211  Where the Heart Is (Oprah's Book Club (Paperba...   \n",
       "4  0385265700   The Book of Ruth (Oprah's Book Club (Paperback))   \n",
       "5  0345342968                                     Fahrenheit 451   \n",
       "6  0060930535                      The Poisonwood Bible: A Novel   \n",
       "7  0375707972                                         The Reader   \n",
       "8  0684872153                    Angela's Ashes (MMP) : A Memoir   \n",
       "\n",
       "           bookAuthor yearOfPublication             publisher  \\\n",
       "0     Emma McLaughlin              2003  St. Martin's Griffin   \n",
       "1        Anita Shreve              1999        Back Bay Books   \n",
       "2     James Patterson              2002         Warner Vision   \n",
       "3        Billie Letts              1998          Warner Books   \n",
       "4       Jane Hamilton              1990                Anchor   \n",
       "5        RAY BRADBURY              1987               Del Rey   \n",
       "6  Barbara Kingsolver              1999             Perennial   \n",
       "7    Bernhard Schlink              1999     Vintage Books USA   \n",
       "8       Frank McCourt              1999              Scribner   \n",
       "\n",
       "                                           imageUrlS  \\\n",
       "0  http://images.amazon.com/images/P/0312291639.0...   \n",
       "1  http://images.amazon.com/images/P/0316601950.0...   \n",
       "2  http://images.amazon.com/images/P/0446610038.0...   \n",
       "3  http://images.amazon.com/images/P/0446672211.0...   \n",
       "4  http://images.amazon.com/images/P/0385265700.0...   \n",
       "5  http://images.amazon.com/images/P/0345342968.0...   \n",
       "6  http://images.amazon.com/images/P/0060930535.0...   \n",
       "7  http://images.amazon.com/images/P/0375707972.0...   \n",
       "8  http://images.amazon.com/images/P/0684872153.0...   \n",
       "\n",
       "                                           imageUrlM  \\\n",
       "0  http://images.amazon.com/images/P/0312291639.0...   \n",
       "1  http://images.amazon.com/images/P/0316601950.0...   \n",
       "2  http://images.amazon.com/images/P/0446610038.0...   \n",
       "3  http://images.amazon.com/images/P/0446672211.0...   \n",
       "4  http://images.amazon.com/images/P/0385265700.0...   \n",
       "5  http://images.amazon.com/images/P/0345342968.0...   \n",
       "6  http://images.amazon.com/images/P/0060930535.0...   \n",
       "7  http://images.amazon.com/images/P/0375707972.0...   \n",
       "8  http://images.amazon.com/images/P/0684872153.0...   \n",
       "\n",
       "                                           imageUrlL  \n",
       "0  http://images.amazon.com/images/P/0312291639.0...  \n",
       "1  http://images.amazon.com/images/P/0316601950.0...  \n",
       "2  http://images.amazon.com/images/P/0446610038.0...  \n",
       "3  http://images.amazon.com/images/P/0446672211.0...  \n",
       "4  http://images.amazon.com/images/P/0385265700.0...  \n",
       "5  http://images.amazon.com/images/P/0345342968.0...  \n",
       "6  http://images.amazon.com/images/P/0060930535.0...  \n",
       "7  http://images.amazon.com/images/P/0375707972.0...  \n",
       "8  http://images.amazon.com/images/P/0684872153.0...  "
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "books_corr_to_bones = pd.DataFrame(['0312291639', '0316601950', '0446610038', '0446672211', '0385265700', '0345342968', '0060930535', '0375707972', '0684872153'], \n",
    "                                  index=np.arange(9), columns=['ISBN'])\n",
    "corr_books = pd.merge(books_corr_to_bones, books, on='ISBN')\n",
    "corr_books"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's select three books to examine from the above highly correlated list \"The Nanny Diaries: A Novel\", \"The Pilot's Wife: A Novel\" and \"Where the heart is\". \n",
    "\n",
    "\"The Nanny Diaries\" satirizes upper class Manhattan society as seen through the eyes of their children's caregivers. \n",
    "\n",
    "Written by the same author of \"The Lovely Bones\", \"The Pilot's Wife\" is the third novel in Shreve's informal trilogy to be set in a large beach house on the New Hampshire coast that used to be a conventis.\n",
    "\n",
    "\"Where the Heart Is\" dramatizes in detail the tribulations of lower-income and foster children in the United States.\n",
    "\n",
    "These three books sound right to me to be highly correlated with \"The Lovely Bones\". Seems our correlation recommender system is working."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
